package com.wdc.hutool;

import java.util.ArrayList;
import java.util.List;

public interface IHandler {
    void handler();

}

class HandlerA implements IHandler {

    @Override
    public void handler() {
        System.out.println("处理了A");

    }
}
class HandlerB implements IHandler {

    @Override
    public void handler() {
        System.out.println("处理了B");

    }
}

class HandlerC implements IHandler {

    @Override
    public void handler() {
        System.out.println("处理了C");

    }
}

class HandlerChain {
    List<IHandler> handlerList = new ArrayList<>();

    public void addHandlers(List<IHandler> handlers) {
        handlerList.addAll(handlers);
    }

    public void handle() {
        handlerList.forEach(IHandler::handler);
    }



}


class Main {
    public static void main(String[] args) {
        HandlerChain handlerChain = new HandlerChain();
        handlerChain.addHandlers(List.of(new HandlerA(), new HandlerB(), new HandlerC()));
        handlerChain.handle();


    }
}